package com.qf.agro.service.device.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.agro.mapper.device.SmartDeviceLogMapper;
import com.qf.agro.pojo.device.SmartDeviceLog;
import com.qf.agro.service.device.SmartDeviceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SmartDeviceLogServiceImpl implements SmartDeviceLogService {
    @Autowired
    private SmartDeviceLogMapper smartDeviceLogMapper;
    @Override
    public Page<SmartDeviceLog> fidnPage(Integer pageNum, Integer pageSize, Long facilitiesId, String name) {
        Page<SmartDeviceLog> page=new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<SmartDeviceLog> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(facilitiesId != null,SmartDeviceLog::getFacilitiesId,facilitiesId);
        queryWrapper.like(name!=null,SmartDeviceLog::getFacilitiesName,name);
        page=smartDeviceLogMapper.selectPage(page,queryWrapper);
        return page;
    }

    @Override
    public void save(SmartDeviceLog smartDeviceLog) {
        smartDeviceLogMapper.insert(smartDeviceLog);
    }
}
